def medical_bayes():
    # 先验概率
    P_disease = 0.01      # 患病率1%
    P_healthy = 0.99      # 健康率99%
    
    # 条件概率
    P_positive_if_disease = 0.99    # 患病者检测阳性概率
    P_positive_if_healthy = 0.01    # 健康者误检阳性概率
    
    # 全概率公式计算检测阳性的总概率
    P_positive = (P_positive_if_disease * P_disease + 
                  P_positive_if_healthy * P_healthy)
    
    # 贝叶斯公式计算后验概率
    P_disease_if_positive = (P_positive_if_disease * P_disease) / P_positive
    
    print(f"即使检测呈阳性，真正患病的概率也只有: {P_disease_if_positive:.2%}")

medical_bayes()